package com.sekill.miaosha.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.seckill.common.core.domain.R;
import com.sekill.miaosha.entity.TbSeckill;
import com.sekill.miaosha.entity.TbStock;
import com.sekill.miaosha.service.ITbSeckillService;
import com.sekill.miaosha.service.ITbStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gao
 * @since 2021-06-18
 */
@RestController
@RequestMapping("/tb-seckill")
public class TbSeckillController {
    @Autowired
    ITbSeckillService seckillService;
    @PostMapping("updateStatusStart")
    public boolean updateStatusStart(TbSeckill seckill){
        seckill.setStatus(1);
        return seckillService.updateById(seckill);
    }
    @PostMapping("updateStatusEnd")
    public boolean updateStatusEnd(TbSeckill seckill){
        seckill.setStatus(0);
        return seckillService.updateById(seckill);
    }
    //查询未上架的
    @GetMapping("getNotOn")
    public List<TbSeckill> getNotOn(){
        QueryWrapper<TbSeckill> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status",1);
       return seckillService.list(queryWrapper);
    }

}
